﻿Imports System
Imports System.Web
Imports System.Web.UI
Imports DotNetNuke
Namespace NVPortal.Modules.NVVideos

    Public MustInherit Class Dropdownlist
        Inherits Entities.Modules.PortalModuleBase

#Region "Controls"
#End Region

#Region "Event Handlers"
        Public Function ReplaceChuoi(ByVal chuoi As String) As String
            Dim convert As String = Global.ReplaceChuoi.bodau(chuoi).Replace(" ", "-")
            Return convert
        End Function
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Try
                If Not IsPostBack Then
                    'Bind video khac
                    Dim ctlPhatSongTime As New NV_VideosController
                    Dim arrPhatSongTime As New ArrayList()
                    arrPhatSongTime = ctlPhatSongTime.GetAllShow(Settings("PortalSetting"))
                    Me.ddlTitle.DataSource = arrPhatSongTime
                    Me.ddlTitle.DataTextField = "Title"
                    Me.ddlTitle.DataValueField = "Videoid"
                    Me.ddlTitle.DataBind()
                    'Cac tin khac cung chuyen muc voi tin nay
                    BindGridData()
                End If
            Catch ex As Exception
                'Me.imgNews.Visible = False
                ' Exception
                ProcessModuleLoadException(Me, ex)
            End Try
        End Sub
        Public Function FormatURL(ByVal sitem As String, ByVal strID As String, ByVal strLink As String) As String
            Dim i As Integer
            If IsNumeric(Settings("NVVideosDisplayPageSetting")) Then
                i = Settings("NVVideosDisplayPageSetting")
                Return "/"
            Else
                Return "/"
            End If
        End Function
        Sub BindGridData()
            Dim ctlNews As New NV_VideosController
            Dim objNews As NV_VideosInfo
            objNews = ctlNews.GetByID(Me.ddlTitle.SelectedValue)
                'Me.lbSummary.Text = objNews.Content
            ' Me.hplTitle.Text = objNews.Title
                If (objNews.Youtube = False) Then
                Dim strFlv As String = "<div id='videocontainer'><embed type='application/x-shockwave-flash'" _
                                            & "src='/DesktopModules/nv_videos/Display/mediaplayer.swf'" _
                                            & "width='385' height='343' style='undefined'" _
                                            & "id='mediaplayer'" _
                                            & "name='mediaplayer'" _
                                            & "quality='high'" _
                                            & "allowfullscreen='true'" _
                                            & "flashvars='width=385&amp;height=343&amp;file=__videoLink__&amp;image=__videoImage__'>"

                strFlv = strFlv.Replace("__videoLink__", objNews.VideoPath)
                strFlv = strFlv.Replace("__videoImage__", objNews.ImagePath)
                    Me.ltrVideo.Text = strFlv
                Else
                Dim strYoute As String = "<iframe width='385' height='343' " _
                    & "allowscriptaccess='always' allowfullscreen='true'" _
                    & "src='https://www.youtube-nocookie.com/embed/__videoLink__'" _
                    & "type='application/x-shockwave-flash'>" _
                    & "</iframe>"
                    strYoute = strYoute.Replace("__videoLink__", objNews.VideoPath)
                    Me.ltrVideo.Text = strYoute
                End If
        End Sub
        Protected Sub ddlTitle_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
            Dim idCountry As String = ddlTitle.SelectedValue.ToString()
            If idCountry.Equals("") Then
                BindGridData()
            Else
                BindGridData()
            End If
        End Sub
#End Region

#Region "Optional Interfaces"

#End Region

    End Class

End Namespace
